import Taro from '@tarojs/taro'
import { View, Image, Text } from '@tarojs/components'
import './index.less'

interface IProps {
  info: obj
}

const goInfo = (e: any) => {
  e.stopPropagation()
  Taro.navigateTo({
    url: '/pages/user-details?id=' + this.info.id
  })
}

const Index = (props: IProps) => {
  const { info } = props
  return (
    <View className="user" onClick={goInfo}>
      <View className="left">
        <slot name="left" />
      </View>
      <View className="avtater">
        <Image src={info.avtater} />
      </View>
      <View className="info">
        <View className="info-content">
          <View className={`nick ${info.userType === 3 || info.isVip ? 'vip' : ''}`}>{info.nick}</View>
          {info.userType !== 3 ? (
            <block>
              {info.isAuth ? (
                <Image className="ic-img" src="https://www.wutuobangxinyougou.com/public/ic/ic_auth.svg" />
              ) : null}
              {info.userType === 5 ? (
                <Image className="ic-img" src="https://www.wutuobangxinyougou.com/public/ic/ic_writer.svg" />
              ) : null}
            </block>
          ) : (
            <Image className="ic-img" src="https://www.wutuobangxinyougou.com/public/ic/ic_sys.svg" />
          )}
          <View className="info-content-more">
            <slot name="content" />
          </View>
        </View>
        <View className="info-des">
          {info.userType === 3 ? (
            <Text>{info.title || info.school}</Text>
          ) : (
            <Text>
              {info.gender}·{info.title || info.school || '重庆某大学'}
            </Text>
          )}
        </View>
      </View>
      <View className="action">
        <slot name="action" />
      </View>
    </View>
  )
}

export default Index
